package com.cskaoyan.javase.practice.stage8.entity;

import com.cskaoyan.javase.practice.stage8.annos.*;

import java.io.Serializable;

/**
 * @program: little-practice
 * @description:
 * @author: Keyu Li
 * @create: 2021-09-19 21:49
 **/


public class Student implements Serializable {
    private int stuId;
    @NameAnno
    private String name;
    @GenderAnno
    private String gender;
    @AgeAnno
    private int age;
    @GradeAnno
    private String grade;
    @PhoneAnno
    private String tele;

    public final static int ELEMENT_NUMBER = 6;

    public void setStuId(int stuId) {
        this.stuId = stuId;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void setGrade(String grade) {
        this.grade = grade;
    }

    public void setTele(String tele) {
        this.tele = tele;
    }

    public int getStuId() {
        return stuId;
    }

    public String getName() {
        return name;
    }

    public String getGender() {
        return gender;
    }

    public int getAge() {
        return age;
    }

    public String getGrade() {
        return grade;
    }

    public String getTele() {
        return tele;
    }

    private Student() {
    }

//    public Student(int stuId, String name, String gender, int age, String grade, String tele) {
//        this.stuId = stuId;
//        this.name = name;
//        this.gender = gender;
//        this.age = age;
//        this.grade = grade;
//        this.tele = tele;
//    }

    public void printStu() {
        System.out.println(this.toString());
    }

    @Override
    public String toString() {
        final StringBuffer sb = new StringBuffer("Student{");
        sb.append("stuId='").append(stuId).append('\'');
        sb.append(", name='").append(name).append('\'');
        sb.append(", gender='").append(gender).append('\'');
        sb.append(", age='").append(age).append('\'');
        sb.append(", grade='").append(grade).append('\'');
        sb.append(", tele='").append(tele).append('\'');
        sb.append('}');
        return sb.toString();
    }


    // 按照年龄对学生数组排序
    public static int sortByAge(Student s1, Student s2) {
        return s1.age - s2.age;
    }

    // 按照学号对学生数组排序
    public static int sortById(Student s1, Student s2) {
        return s1.stuId - s2.stuId;
    }

    // 按照先年龄、后学号对学生数组排序
    public static int sortByAgeAndId(Student s1, Student s2) {
        if (s1.age != s2.age) return s1.age - s2.age;
        return s1.stuId - s2.stuId;
    }
}

